public class LambdaExample {



    public static void main(String[] args)
    {


        Calculator adder =(a,b)->a+b;
        Calculator Subtraction =(a,b)->a-b;
        Calculator Multiplicationr =(a,b)->a*b;
       Calculator Division =(a,b)->a/b;





        int result1 = adder.calculate(5,3);
        int result2 = Subtraction.calculate(5,3);
        int result3 = Subtraction.calculate(5,3);
        int result4 = Division.calculate(5,3);

        System.out.println("使用Lambda表达式实现的加法结果为"+result1);
        System.out.println("使用Lambda表达式实现的减法结果为"+result2);
        System.out.println("使用Lambda表达式实现的乘法结果为"+result3);
        System.out.println("使用Lambda表达式实现的除法结果为"+result4);




  /*      Calculator adder =new Calculator(){
            @Override
            public int calculate(int a,int b)
                {
                    return  a+b;
                }
        };

        int result = adder.calculate(5,3);
        System.out.println("使用外部类实现的加法结果为"+result);*/

    }
}
